﻿using System;
using System.Linq.Expressions;

public class WebServer
{
    public void BootstrapServer(int port, string rootDirectory, string serverName)
    {
        if (rootDirectory == null)
        {
            throw new ArgumentNullException("rootDirectory");
        }
        if (serverName == null)
        {
            throw new ArgumentNullException("serverName");
        }

        // Bootstrap the server
    }
}

public class WebServer_StaticReflectionGuards
{
    public void BootstrapServer(int port, string rootDirectory, string serverName)
    {
        Guard.IsNotNull(() => rootDirectory);
        Guard.IsNotNull(() => serverName);

        // Bootstrap the server
    }
}

public static class Guard
{
    public static void IsNotNull<T>(Expression<Func<T>> expr)
    {
        // expression value != default of T
        if (!expr.Compile()().Equals(default(T)))
            return;

        var param = (MemberExpression)expr.Body;
        throw new ArgumentNullException(param.Member.Name);
    }
}
